package com.oyo.common.request;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oyo.common.enums.EnumVersion;
import com.oyo.common.enums.VersionHelper;

import java.io.Serializable;

/**
 * @author zhangyang
 * @date 2018/7/25 统一接受的参数对象
 */
public class BaseRequest implements Serializable {
	private static final long serialVersionUID = -4832529620261989152L;
	/**
	 * 第一渠道 ANDROID IPHONE TOUCH
	 */
	private String firstChannel;
	/**
	 * 第二渠道
	 */
	private String secondChannel;
	/**
	 * 接口名
	 */
	private String method;
	/***/
	private String token;
	/**
	 * app版本（版本号格式为1.0.0）
	 */
	private String appVersion;

	/**
	 * 手机操作系统版本号
	 */
	private String osVersion;
	/**
	 * 设备名称
	 */
	private String deviceName;

	/**
	 * 请求信息
	 */
	private HttpServletRequest request;
	/**
	 * 响应信息
	 */
	private HttpServletResponse response;

	/**
	 * 设备唯一码
	 */
	private String deviceToken;

	public void setAppVersion(String appVersion) {
		this.appVersion = appVersion;
	}

	public String getDeviceToken() {
		return deviceToken;
	}

	public void setDeviceToken(String deviceToken) {
		this.deviceToken = deviceToken;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	/**
	 * 获取客户端版本
	 * 
	 * @return 版本号
	 */
	public String getAppVersion() {
		return appVersion;
	}

	/**
	 * 获取客户端的版本
	 *
	 * @return 版本号
	 */
	public EnumVersion getClientVersion() {
		return EnumVersion.create(appVersion);
	}

	public boolean gt(EnumVersion version) {
		return VersionHelper.gt(getClientVersion(), version);
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public String getOsVersion() {
		return osVersion;
	}

	public void setOsVersion(String osVersion) {
		this.osVersion = osVersion;
	}

	public String getDeviceName() {
		return deviceName;
	}

	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}

	public String getFirstChannel() {
		return firstChannel;
	}

	public void setFirstChannel(String firstChannel) {
		this.firstChannel = firstChannel;
	}

	public String getSecondChannel() {
		return secondChannel;
	}

	public void setSecondChannel(String secondChannel) {
		this.secondChannel = secondChannel;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	@Override
	public String toString() {
		return "RopRequest [method=" + method + ", appVersion=" + appVersion + ", osVersion=" + osVersion
				+ ", deviceName=" + deviceName + ", firstChannel=" + firstChannel + ", secondChannel=" + secondChannel
				+ ", request=" + request + ", response=" + response + ",   deviceToken=" + deviceToken + ", deviceName="
				+ deviceName + "]";
	}

}
